package com.example.sxt_practise.reflection;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 * java脚本引擎是从jdk1.6之后添加的新功能
 * @author gaofeng
 * @date 2022年06月05日 20:37
 */
public class ScriptEngineManagerTest {
    public static void main(String[] args) {
        ScriptEngineManager engineManager = new ScriptEngineManager();
        ScriptEngine javascript = engineManager.getEngineByName("javascript");

        javascript.put("msg", "2 * 3 - 4");

        try {
            javascript.eval("2 * 3 - 4") ;
        } catch (ScriptException e) {
            e.printStackTrace();
        }
    }
}
